package com.woniu.backstage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.backstage.common.PageResult;
import com.woniu.backstage.dao.TbVipMapper;
import com.woniu.backstage.entity.TbVip;
import com.woniu.backstage.service.ITbVipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 会员表 服务实现类
 * </p>
 *
 * @author spirit
 * @since 2020-04-17
 */
@Service
public class TbVipServiceImpl extends ServiceImpl<TbVipMapper, TbVip> implements ITbVipService {

    @Autowired
    private TbVipMapper vipMapper;

    @Override
    public PageResult getAllVip(Integer currentPage, Integer pageSize) {
        //查询出总的数据条数
        Integer total = vipMapper.getTotal();
        //计算出开始的数据
        int begin = (currentPage-1)*pageSize;
        //查询出数据
        List<TbVip> vipList = vipMapper.getAllVip(begin, pageSize);
        PageResult pageResult = new PageResult(0,"success",vipList,currentPage,total);
        return pageResult;
    }

    @Override
    public int addVip(TbVip vip) {
        return vipMapper.insert(vip);
    }

    @Override
    public int deleteVip(Serializable id) {
        return vipMapper.deleteById(id);
    }

    @Override
    public int updateVip(TbVip vip) {
        return vipMapper.updateVip(vip);
    }

    @Override
    public Integer deleteBatch(List<Integer> idArr) {
        return vipMapper.deleteBatch(idArr);
    }
}
